%s/\s\+$//e
7
normal gqap
%s/Copyright 2007 Chandler Carruth/Copyright 2007, 2008 Chandler Carruth/e
%s/_parser_\(\(\w\|_\)\+\)_header_/inc_parser_\1_header/
%s/^#\(include\|ifn\?def\|define\)\s\+/#\1 /e
%s:^//  includes\n\(#include.*\n\+\)\+:#include <string>\r\r#include <boost/scoped_ptr.hpp>\r\r#include <inc/parser/parse_tree_node.hpp>\r\rnamespace inc {\rnamespace parser {\r\r//  FORWARD DECLS\r\r:
global/^\n\zs\/\/\/$/+1delete
global/^\/\/\/\n$/delete
global/^\s*\/\/\/\s\+\\name/.,+1delete
global/^\s*\/\/@}/delete
%s:^\(/// \\\(brief\|file\|author\|date\)\)\s\+:\1 :e
%s:\\file \./include/:\\file ./include/inc/parser/:
%s/^\s*virtual bool\s*create(\_[^)]*);$//
%s/^\s*virtual bool\s*destroy(\_[^)]*);$//
%s/^\s*bool\s*init(\_[^)]*);$//
%s/^\s*bool\s*deinit(\_[^)]*);$//
%s/: private wsParser$//e
%s/private wsParser, //e
%s/\w\+Node/\u&/g
%s/class\s\+\(\w*\) : .*\n{\npublic:\n$/&  \1();\r  virtual \~\1();\r\r  virtual bool parse( const iterator\& first,\r                      const iterator\& last,\r                      iterator\& last_parsed );\r/
%s/class\s\+/class /
global/^protected:\n\n\+private:$/delete
%s/^\(\(\s*\w\+[*&]\?\s\+\w\+\(_\w\+\)*;\n\+\)\+\)\(\_.*\nprivate:\)/\4\r\1/e
%s/^\(\s\+\)\(\w\+\)\*\s\+\(\w\+\(_\w\+\)*\);$/\1boost::scoped_ptr<\2> \3;/e
let my_classes = {}
1
while search('scoped_ptr<\w\+>', 'W')
  let my_classes[matchstr(getline('.'), 'scoped_ptr<\zs\w\+')] = 1
endwhile
for my_class in sort(keys(my_classes))
  echo "Adding " . my_class . "..."
  %s:^//  FORWARD DECLS$:\="class " . my_class . ";\r" . submatch(0):
endfor
global/^\/\/  FORWARD DECLS$/delete
%s/^\n$//e
global/^\%$/delete
%s:^#endif.*\%$:} //  end parser namespace\r} //  end inc namespace\r&:

